#include<bits/stdc++.h>
using namespace std;

struct node {
	int x, y, z;
} a[50005];

signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].x >> a[i].y >> a[i].z;
	}

	sort(a + 1, a + n + 1, [](node x, node y) {
		return x.z < y.z;
	});

	double ans = 0;
	for (int i = 1; i < n; i++) {
		ans += sqrt((a[i].x - a[i + 1].x) * (a[i].x - a[i + 1].x) + (a[i].y - a[i + 1].y) * (a[i].y - a[i + 1].y) + (a[i].z - a[i + 1].z) * (a[i].z - a[i + 1].z));
	}
	cout << fixed << setprecision(3) << ans;
	return 0;
}
